home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Documents / JAVA Programming / examples / 09 / toStringDemo.java < prev   
Encoding:
Java Source  |  2000-09-08  |  285 b   |  15 lines

  1. class Point { 
  2. int x, y;
  3. Point(int x, int y) {
  4. this.x = x;
  5. this.y = y;
  6. }
  7. public String toString() {
  8. return "Point[" + x + ", " + y + "]";
  9. } } 
  10. class toStringDemo {
  11. public static void main(String args[]) { 
  12. Point p = new Point(10, 20);
  13. System.out.println("p = " + p);
  14. } }
  15.